<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
  
  <head>    
    <title>Custom model with an animated in-game material</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link href="../../styles.css" rel="stylesheet">
    <link rel="icon" href="../../images/icon.png">
	</head>

	<body>

    <div id="top">
      <h1>Custom model with an animated in-game material</h1> 
    </div>
			
    <div id="hot-links">
      <h2>Direct links</h2>
      <hr>
      <ol>
        <li><a href="../../index.html">Introduction</a></li>
        <li><a href="../tutorials.html">Tutorials</a></li>
        <li><a href="../resources.html">Resources</a></li>
      </ol>
    </div>
			
    <div id="main">
        
      <h2>Contents</h2>
      <hr>
      <ol>
        <li><a href="#tools">Required tools</a></li>
        <li><a href="#tutorials">Required tutorials</a></li>
        <li><a href="#steps">Steps</a></li>
      </ol>
      <br>

      <hr id="tools">
      <h2>Required tools</h2>
      <hr>
      <p>Go to <a href="../resources.html">Resources</a> for download links.</p>        
      <ul>
        <li>Blender</li>
        <li>SuperBMD</li>
        <li>j3dview</li>
        <li>Any text editor you like (Notepad++ is recommended)</li>
        <li>Collision Creator</li>
        <li>Arc Convertor</li>
        <li>Whitehole</li>
        <li>Wiimm's ISO Tools (to get your SMG1 dump)</li>
      </ul>
      <br>

      <hr id="tutorials">
      <h2>Required tutorials</h2>
      <hr>
      <ul>
        <li><a href="t1.html">How to import a custom model into SMG1</a></li>
        <li><a href="t2.html">How to import a custom model into SMG1 with 1 in-game material</a></li>
        <li><a href="t3.html">How to import a custom model into SMG1 with 2 or more in-game materials</a></li>
      </ul>
      <br>

      <hr id="steps">
      <h2>Steps --- files used: <a href="https://archive.org/download/humming-owl-storage/tutorial4.zip">tutorial4.zip</a></h2>
      <hr>

      <p>First, locate the in-game model containing the <b>animated material</b> you want, I will choose the <b>lava material</b> this object has (<code>IceLavaIslandLavaMovableStepA</code> located in <code>IceVolcanoGalaxy</code>, <b>Fig. 1</b>).</p>

      <img src="../../images/t4/fig1.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 1 - Model containing the animated lava)</p>
      <br>

      <p>Do the same mentioned in the <b>previous tutorials</b> to get the <b>material’s name</b> (through the <b>DAE file</b> exported by <b>SuperBMD</b> and opened in <b>Blender</b> or by guessing the <b>material</b> by its associated <b>textures</b> from the <b>JSON files</b> exported by <b>SuperBMD</b>). In this case it is rapidly done by guessing the <b>material</b> from its <b>texture</b> associated from the <b>material JSON file</b>, since the <b>lava texture</b> is very notable (this material comes with <b>2 textures</b>, <b>Fig. 2</b>).</p>

      <img src="../../images/t4/fig2.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 2 - Material name search method with recognizable texture)</p>
      <br>

      <p>Assign a <b>material</b> with the same name as the <b>target material</b> to the custom model on <b>Blender</b> and set up the special effects the model will have so that the texture looks nice (remember to <b>triangulate your model</b>, <b>scale it</b> and <b>reset the models properties</b> with the <b>Ctrl + A</b> functions at the end, <b>Fig. 3</b>).</p>

      <img src="../../images/t4/fig3.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 3 - Custom model with respective textures/materials applied)</p>
      <br>

      <hr>
      <p><b>NOTE 1:</b> in the contextual menu containing the <b>unwrap options</b> there are other options that might also be helpful when applying a <b>texture</b> the faces of an object, every one of them <b>unwraps</b> in a different way (experiment with them). I used the <code>Sphere Projection</code> <b>unwrap</b> method to get a better and rapid result for this object.</p>
      <hr>

      <br>

      <p>Export your object as a <b>FBX and OBJ files</b> to a known location and then put in the same location the <b>textures</b> used and both <b>JSON files</b> from the original model (<b>Fig. 4</b>). As this object only requires a <b>single material</b> we can skip doing the <b>materials/textures JSON file</b> from the previous tutorial and use the ones from the in-game model by removing the <b>unused textures</b> from the <b>textures JSON file</b> so that <b>SuperBMD</b> does not crash (<b>Fig. 5</b>).</p>

      <img src="../../images/t4/fig4.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 4 - Needed files in the same location)</p>
      <br>

      <img src="../../images/t4/fig5.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 5 - Unused texture removal from the textures JSON)</p>
      <br>

      <p>Create a <b>BMD file</b> using <b>SuperBMD</b> with the following command replacing the pertinent filenames:</p>
      
      <p><code>path\to\SuperBMD.exe object-name.fbx --mat materials.json --texheader textures.json --rotate --nosort</code></p>
      
      <p>and get the <b>KCL and PA files</b> with <b>NeoKCLCreate</b> (I choose "<code>Lava</code>" for the <b>floor code</b> :P). Open and save the <b>BMD file</b> created from <b>SuperBMD</b> as a <b>BDL file</b> with <b>j3dview</b> and then put the <b>BDL, KCL and PA files</b> into a common folder named exactly as them (<b>Fig. 6</b>).</p>

      <img src="../../images/t4/fig6.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 6 - BDL, KCL and PA files)</p>
      <br>

      <p>Now, with that being done, it is time to put the <b>texture animation file</b> inside that same folder. <b>BTK files</b> are <b>texture animation files</b> (<a href="https://luma.aurumsmods.com/wiki/Category:File_formats">File formats</a>). When extracting the contents of the <b>BDL file</b> of the original model containing the animated <b>material</b>, a <b>BTK file</b> will be extracted, copy that file into the folder of your custom model and rename it as your model (<b>Fig. 7a and 7b</b>). This is basically the only thing to do to import a <b>material animation</b> to your model (being honest, thank god it is).</p>

      <img src="../../images/t4/fig7a.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 7a - In-game model BTK file)</p>
      <br>

      <img src="../../images/t4/fig7b.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 7b - Same BTK file renamed to the name of the custom model)</p>
      <br>

      <p><b>At this point you know what to do:</b> Generate an <b>ARC file</b> with the mentioned folder, <b>yaz0enc</b> it, rename the output file to <b>ARC only</b>, copy that <b>ARC file</b> to the <code>ObjectData</code> folder of your <b>SMG1 dump</b>, open <b>Whitehole</b>, open the <code>PlanetMapDataTable</code> with <b>Whitehole’s</b> <b>BCSV editor</b> and add your <b>custom model</b> to a new row, save, open a <b>Galaxy</b> of your choice, place any object on the <b>Galaxy</b>, change its "<b>Object property</b> to match your <b>custom model name</b>, and, if everything went correctly, you model will appear in "<b>Whitehole</b>. Next is to test on game! (<b>Fig. 8</b>)</p>

      <img src="../../images/t4/fig8.jpg" alt="Image could not be loaded.">
      <p class="idtext">(Fig. 8 - Mario chilling VERY CLOSE to a body of HOT lava)</p>
      <br>

      <hr>
      <p><b>NOTE 2:</b> you cannot see the <b>lava animation</b> in <b>Fig. 8</b> but it was applied correctly.</p>
      <hr>
      
      <br>

    </div>

  </body>

</html>
